<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    function ajax(method,url,callback){
        var xhr = new XMLHttpRequest();
        xhr.open(method,url);
        xhr.send();
        xhr.onreadystatechange =function(){
            if(xhr.readyState === 4 && /^2\d{2}/.test(xhr.status)){
                //成功之后
                callback(xhr.responseText);
            }
        }
    }
    ajax("GET","./test.php",function(data){
        console.log(data)
    })
</script>